package com.aabte.design2.structural.composite;

import lombok.Data;

/**
 * 叶节点类代表组合的终端对象。叶节点对象中不能包含任何子对象。叶节点对象
 * 通常会完成实际的工作，组合对象则仅会将工作委派给自己的子部件。
 *
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
@Data
public class Dot implements Graphic {

    private int x;
    private int y;

    public Dot(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public void move(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public void draw(int level) {
        StringBuilder spaces = new StringBuilder();
        for (int i = 0; i < level; i++) {
            spaces.append("  ");
        }
        System.out.println(spaces + this.getClass().getSimpleName() + "#draw" + " x = " + x + ", y = " + y);
    }
}
